﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/MasterPage.Master" AutoEventWireup="true" CodeBehind="ManageAddresses.aspx.cs" Inherits="DrivingCRM.Views.Private.CRM.ManageAdresses" %>

<asp:Content ID="Content1" ContentPlaceHolderID="title" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="banniere" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="nav" runat="server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="contenu" runat="server">
    <h2>Gestion des adresses</h2>
    <asp:ListView ID="LV_Addresses" runat="server" DataKeyNames="IdAdress" 
        DataSourceID="DS_Addresses" GroupItemCount="3"
        InsertItemPosition="None" OnItemCanceling="LV_Adresses_ItemCanceling"
        OnItemInserting="LV_Adresses_ItemInserting" OnItemEditing="LV_Adresses_ItemEditing" OnItemUpdating="LV_AdressesItemUpdating">
        <AlternatingItemTemplate>
            <td runat="server" style="background-color:#FFF8DC;">
                <table class="Table_ItemList">
                    <tr>
                        <td>Numéro:</td>
                        <td><asp:Label ID="NumberLabel" runat="server" Text='<%# Eval("Number") %>' /></td>
                    </tr>
                    <tr>
                        <td>Type de rue:</td>
                       <td><asp:Label ID="StreetTypeLabel" runat="server" 
                                Text='<%# Eval("StreetType.Type") %>' /></td>
                    </tr>
                    <tr>
                        <td>Nom de la rue:</td>
                        <td><asp:Label ID="StreetNameLabel" runat="server" 
                                Text='<%# Eval("StreetName") %>' /></td>
                    </tr>
                    <tr>
                        <td>Compléments:</td>
                        <td><asp:Label ID="ExtraLabel" runat="server" Text='<%# Eval("Extra") %>' /></td>
                    </tr>
                    <tr>
                        <td>Code postal:</td>
                        <td><asp:Label ID="ZipcodeLabel" runat="server" Text='<%# Eval("Zipcode") %>' /></td>
                    </tr>
                    <tr>
                        <td>Ville:</td>
                        <td><asp:Label ID="CityLabel" runat="server" Text='<%# Eval("City") %>' /></td>
                    </tr>
                    <tr>
                        <td>Cedex:</td>
                        <td><asp:Label ID="CedexLabel" runat="server" Text='<%# Eval("Cedex") %>' /></td>
                    </tr>
                    <tr>
                        <td><asp:Button ID="DeleteButton" runat="server" CommandName="Delete" 
                        Text="Supprimer" /></td>
                        <td><asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Modifier" /></td>
                    </tr>
                </table>
            </td>
        </AlternatingItemTemplate>
        <EditItemTemplate>
            <td id="Td2" runat="server" style="background-color:#008A8C;color: #FFFFFF;">
                <table class="Table_ItemList">
                    <tr>
                        <td>Numéro:</td>
                        <td>
                            <asp:TextBox ID="NumberTextBox" runat="server" Text='<%# Bind("Number") %>' />
                            <asp:RequiredFieldValidator ID="NumberRequired" runat="server" 
                                ControlToValidate="NumberTextBox" ErrorMessage="Le numéro est requis." 
                                ToolTip="Le numéro est requis." ValidationGroup="ManageAdress_Edit">*</asp:RequiredFieldValidator>
                         </td>
                    </tr>
                    <tr>
                        <td>Type de rue:</td>
                        <td>
                            <asp:DropDownList ID="DDL_StreetType" runat="server" DataSourceID="DS_StreetTypes" 
                                DataTextField="Type" DataValueField="Id">
                            </asp:DropDownList>

                            <asp:EntityDataSource ID="DS_StreetTypes" runat="server" 
                                ConnectionString="name=Model_DrivingCRMContainer" 
                                DefaultContainerName="Model_DrivingCRMContainer" EnableFlattening="False" 
                                EntitySetName="StreetTypeSet" EntityTypeFilter="StreetType">
                            </asp:EntityDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td>Nom de la rue:</td>
                        <td>
                            <asp:TextBox ID="StreetNameTextBox" runat="server" 
                                Text='<%# Bind("StreetName") %>' />
                            <asp:RequiredFieldValidator ID="StreetNameRequired" runat="server" 
                                ControlToValidate="StreetNameTextBox" ErrorMessage="Le nom de la rue est requis." 
                                ToolTip="Le nom de la rue est requis." ValidationGroup="ManageAdress_Edit">*</asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>Compléments (facultatif):</td>
                        <td><asp:TextBox ID="ExtraTextBox" runat="server" Text='<%# Bind("Extra") %>' /></td>
                    </tr>
                    <tr>
                        <td>Code postal:</td>
                        <td>
                            <asp:TextBox ID="ZipcodeTextBox" runat="server" Text='<%# Bind("Zipcode") %>' />
                            <asp:RequiredFieldValidator ID="ZipCodeRequired" runat="server" 
                                ControlToValidate="ZipcodeTextBox" ErrorMessage="Le code postal est requis." 
                                ToolTip="Le code postal est requis." ValidationGroup="ManageAdress_Edit">*</asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>Ville:</td>
                        <td>
                            <asp:TextBox ID="CityTextBox" runat="server" Text='<%# Bind("City") %>' />
                            <asp:RequiredFieldValidator ID="CityRequired" runat="server" 
                                ControlToValidate="CityTextBox" ErrorMessage="La Ville est requise." 
                                ToolTip="La Ville est requise." ValidationGroup="ManageAdress_Edit">*</asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>Cedex (facultatif):</td>
                        <td><asp:TextBox ID="CedexTextBox" runat="server" Text='<%# Bind("Cedex") %>' /></td>
                    </tr>
                    <tr>
                        <td><asp:Button ID="UpdateButton" runat="server" CommandName="Update" 
                        Text="Mettre à jour" /></td>
                        <td><asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                        Text="Annuler" /></td>
                    </tr>
                    <tr>
                        <td align="center" colspan="2" style="color:Red;">
                            <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
                        </td>
                    </tr>
                </table>
            </td>
        </EditItemTemplate>
        <EmptyDataTemplate>
            <table id="Table1" runat="server" 
                style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
                <tr>
                    <td>
                        <h2>Aucune adresse en base.</h2></td>
                </tr>
                <tr>
                    <td><asp:Button ID="B_AddAddress" runat="server" Text="Ajouter une adresse" OnClick="B_AddAddress_Click" /></td>
                </tr>
            </table>
        </EmptyDataTemplate>
        <EmptyItemTemplate>
            <td id="Td3" runat="server" />
        </EmptyItemTemplate>
        <GroupTemplate>
            <tr ID="itemPlaceholderContainer" runat="server">
                <td ID="itemPlaceholder" runat="server">
                </td>
            </tr>
        </GroupTemplate>
        <InsertItemTemplate>
            <td id="Td4" runat="server" style="">
                <table class="Table_ItemList">
                    <tr>
                        <td>Numéro:</td>
                        <td>
                            <asp:TextBox ID="NumberTextBox" runat="server" Text='<%# Bind("Number") %>' />
                            <asp:RequiredFieldValidator ID="NumberRequired" runat="server" 
                                ControlToValidate="NumberTextBox" ErrorMessage="Le numéro est requis." 
                                ToolTip="Le numéro est requis." ValidationGroup="ManageAdress_Insert">*</asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>Type de rue:</td>
                        <td>
                            <asp:DropDownList ID="DDL_StreetType" runat="server" DataSourceID="DS_StreetTypes" 
                                DataTextField="Type" DataValueField="Id">
                            </asp:DropDownList>

                            <asp:EntityDataSource ID="DS_StreetTypes" runat="server" 
                                ConnectionString="name=Model_DrivingCRMContainer" 
                                DefaultContainerName="Model_DrivingCRMContainer" EnableFlattening="False" 
                                EntitySetName="StreetTypeSet" EntityTypeFilter="StreetType">
                            </asp:EntityDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td>Nom de la rue:</td>
                        <td>
                            <asp:TextBox ID="StreetNameTextBox" runat="server" 
                                Text='<%# Bind("StreetName") %>' />
                            <asp:RequiredFieldValidator ID="StreetNameRequired" runat="server" 
                                ControlToValidate="StreetNameTextBox" ErrorMessage="Le nom de la rue est requis." 
                                ToolTip="Le nom de la rue est requis." ValidationGroup="ManageAdress_Insert">*</asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>Compléments (facultatif):</td>
                        <td><asp:TextBox ID="ExtraTextBox" runat="server" Text='<%# Bind("Extra") %>' /></td>
                    </tr>
                    <tr>
                        <td>Code postal:</td>
                        <td>
                            <asp:TextBox ID="ZipcodeTextBox" runat="server" Text='<%# Bind("Zipcode") %>' />
                            <asp:RequiredFieldValidator ID="ZipCodeRequired" runat="server" 
                                ControlToValidate="ZipcodeTextBox" ErrorMessage="Le code postal est requis." 
                                ToolTip="Le code postal est requis." ValidationGroup="ManageAdress_Insert">*</asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>Ville:</td>
                        <td>
                            <asp:TextBox ID="CityTextBox" runat="server" Text='<%# Bind("City") %>' />
                            <asp:RequiredFieldValidator ID="CityRequired" runat="server" 
                                ControlToValidate="CityTextBox" ErrorMessage="La Ville est requise." 
                                ToolTip="La Ville est requise." ValidationGroup="ManageAdress_Insert">*</asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td>Cedex (facultatif):</td>
                        <td><asp:TextBox ID="CedexTextBox" runat="server" Text='<%# Bind("Cedex") %>' /></td>
                    </tr>
                    <tr>
                        <td><asp:Button ID="UpdateButton" runat="server" CommandName="Insert" 
                        Text="Ajouter" /></td>
                        <td><asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                        Text="Annuler" /></td>
                    </tr>
                    <tr>
                        <td align="center" colspan="2" style="color:Red;">
                            <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
                        </td>
                    </tr>
                </table>
            </td>
        </InsertItemTemplate>
        <ItemTemplate>
            <td id="Td5" runat="server" style="background-color:#DCDCDC;color: #000000;">
                <table class="Table_ItemList">
                    <tr>
                        <td>Numéro:</td>
                        <td><asp:Label ID="NumberLabel" runat="server" Text='<%# Eval("Number") %>' /></td>
                    </tr>
                    <tr>
                        <td>Type de rue:</td>
                        <td><asp:Label ID="StreetTypeLabel" runat="server" 
                                Text='<%# Eval("StreetType.Type") %>' /></td>
                    </tr>
                    <tr>
                        <td>Nom de la rue:</td>
                        <td><asp:Label ID="StreetNameLabel" runat="server" 
                                Text='<%# Eval("StreetName") %>' /></td>
                    </tr>
                    <tr>
                        <td>Compléments (facultatif):</td>
                        <td><asp:Label ID="ExtraLabel" runat="server" Text='<%# Eval("Extra") %>' /></td>
                    </tr>
                    <tr>
                        <td>Code postal:</td>
                        <td><asp:Label ID="ZipcodeLabel" runat="server" Text='<%# Eval("Zipcode") %>' /></td>
                    </tr>
                    <tr>
                        <td>Ville:</td>
                        <td><asp:Label ID="CityLabel" runat="server" Text='<%# Eval("City") %>' /></td>
                    </tr>
                    <tr>
                        <td>Cedex (facultatif):</td>
                        <td><asp:Label ID="CedexLabel" runat="server" Text='<%# Eval("Cedex") %>' /></td>
                    </tr>
                    <tr>
                        <td><asp:Button ID="DeleteButton" runat="server" CommandName="Delete" 
                        Text="Supprimer" /></td>
                        <td><asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Modifier" /></td>
                    </tr>
                </table>
            </td>
        </ItemTemplate>
        <LayoutTemplate>
            <table id="Table2" runat="server">
                <tr id="Tr1" runat="server">
                    <td id="Td6" runat="server">
                        <table ID="groupPlaceholderContainer" runat="server" border="1" 
                            style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
                            <tr ID="groupPlaceholder" runat="server">
                            </tr>
                        </table>
                    </td>
                </tr>

                <%-- Ligne contenant le bouton d'affichage de la ligne d'ajout d'une adresse --%>
                <tr id="Tr2" runat="server">
                    <td id="Td1" runat="server">
                        <asp:Button ID="B_DisplayInsert" runat="server" Text="Ajouter une adresse" OnClick="B_AddAddress_Click" />
                    </td>
                </tr>

                <tr id="Tr3" runat="server">
                    <td id="Td7" runat="server" 
                        style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;">
                        <asp:DataPager ID="DataPager1" runat="server" PageSize="12">
                            <Fields>
                                <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
                                    ShowNextPageButton="False" ShowPreviousPageButton="False" PreviousPageText="Précédent" FirstPageText="Première page" />
                                <asp:NumericPagerField />
                                <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" 
                                    ShowNextPageButton="False" ShowPreviousPageButton="False" NextPageText="Suivant" LastPageText="Dernière page" />
                            </Fields>
                        </asp:DataPager>
                    </td>
                </tr>
            </table>
        </LayoutTemplate>
        <SelectedItemTemplate>
        </SelectedItemTemplate>
    </asp:ListView>
    <asp:EntityDataSource ID="DS_Addresses" runat="server" 
        ConnectionString="name=Model_DrivingCRMContainer" 
        DefaultContainerName="Model_DrivingCRMContainer" EnableDelete="True" 
        EnableInsert="True" EnableUpdate="True" EntitySetName="AddressSet" 
        EntityTypeFilter="Address" Include="StreetType">
    </asp:EntityDataSource>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="footer" runat="server">
</asp:Content>

